import types from '../types';

// 状态管理
const state = {
  isLaunchReady: false, // onLanuch 是否完成
  isAppReady: false, // 是否初始化完成
  initPath: '', // 初始路由
  initQuery: '', // 初始路由参数
  statusBarHeight: 20, // 状态栏高度
  gap: 4, // 胶囊与状态栏间距
};

// 调用时机
const actions = {
  setInitPathQuery({ commit }, status) {
    commit(types.INIT_PATH_QUERY, status);
  },
  setStatusBarHeight({ commit }, status) {
    commit(types.BAR_HEIGHT_GET, status);
  },
  setGap({ commit }, status) {
    commit(types.BAR_HEIGHT_GAP, status);
  },
};

// 处理逻辑
const mutations = {
  [types.SET_LAUNCH_READY](_state, status) {
    _state.isLaunchReady = status;
  },
  [types.IS_APP_READY](_state, status) {
    _state.isAppReady = status;
  },
  [types.BAR_HEIGHT_GET](_state, status) {
    _state.statusBarHeight = status;
  },
  [types.BAR_HEIGHT_GAP](_state, status) {
    _state.gap = status;
  },
};

export default {
  state,
  actions,
  mutations,
};
